home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks95 / IsNative.sit / Is Native / MyDrawMenuBar.c < prev    next >
Text File  |  1995-06-24  |  2KB  |  111 lines

  1. //
  2. // File:    MyDrawMenuBar.c
  3. // Project:    IsNative.π
  4. // Author:    Glenn L. Austin
  5. //            Symantec Corporation
  6. //
  7. #include "IsNative.h"
  8.  
  9. static short    cWidth = 0;
  10.  
  11. typedef struct {
  12.     MenuHandle    menuOH;
  13.     short        menuLeft;
  14. } ItemMenu;
  15.  
  16. typedef struct {
  17.     short    lastMenu;
  18.     short    lastRight;
  19.     short    mbResID;
  20.     ItemMenu    menuInfo[2];    // only need information on the Apple & File menus
  21. } MyMenuListRec;
  22.  
  23. pascal void MyDrawMenuBar(void)
  24. {
  25.     long        oldA4 = SetA4World();
  26.     GrafPtr        oldPort, wMgrPort;
  27.     short        txFont, txSize, txMode;
  28.     Style        txFace;
  29.     short        cWidth;
  30.     MyAppInfo*    info;
  31.     GDHandle    mainGD;
  32.     
  33.     (*glob->oldDrwMBarTrap)();
  34.     
  35.     info = FindAppInfo(LMGetCurApName());
  36.     if (info && (info->flags & kIsNative) && *(short *) *LMGetMenuList())
  37.     {
  38.         Boolean        colorApple;
  39.         GDevice*    gd;
  40.         short        mLeft, mRight;
  41.         
  42.         {
  43.             MyMenuListRec    *mmlr = *(MyMenuListRec**) LMGetMenuList();
  44.             
  45.             mLeft = mmlr->menuInfo[0].menuLeft;
  46.             if (mmlr->lastMenu >= OFFSET(MyMenuListRec,menuInfo[1]))
  47.                 mRight = mmlr->menuInfo[1].menuLeft;
  48.             else
  49.                 mRight = mmlr->lastRight;
  50.         }
  51.         
  52.         mainGD = GetMainDevice();
  53.         gd = *mainGD;
  54.         
  55.         colorApple = false;
  56.         if ((**(*gd).gdPMap).pixelSize > 4)            // need to check for Grays
  57.             colorApple = !!(gd->gdFlags & 0x0001);
  58.  
  59.         GetPort(&oldPort);
  60.         GetWMgrPort(&wMgrPort);
  61.         SetPort(wMgrPort);
  62.         
  63.         txFont = wMgrPort->txFont;
  64.         txSize = wMgrPort->txSize;
  65.         txMode = wMgrPort->txMode;
  66.         txFace = wMgrPort->txFace;
  67.         
  68.         TextFont(geneva);
  69.         TextSize(9);
  70.         if (colorApple)
  71.         {
  72.             TextFace(italic | bold);
  73.             TextMode(srcOr);
  74.         }
  75.         else
  76.         {
  77.             TextFace(0);
  78.             TextMode(srcXor);
  79.         }
  80.         
  81.         cWidth = CharWidth('N');
  82.         
  83.         if (colorApple)
  84.         {
  85.             // since the 'N' is italic, I want it to start 1 pixel to the left of where
  86.             // it would normally be...
  87.             MoveTo(mLeft + ((mRight - mLeft) >> 1) - (cWidth >> 1) - 1, 14);
  88.             DrawChar('N');
  89.         }
  90.         else
  91.         {
  92.             Rect    r = {0, 0, 1, 3};
  93.             
  94.             OffsetRect(&r, mLeft + ((mRight - mLeft) >> 1), 9);
  95.             EraseRect(&r);
  96.             --r.top;
  97.             ++r.bottom;
  98.             ++r.left;
  99.             --r.right;
  100.             EraseRect(&r);
  101.         }
  102.         
  103.         TextFont(txFont);
  104.         TextSize(txSize);
  105.         TextFace(txFace);
  106.         TextMode(txMode);
  107.     }
  108.     
  109.     RestoreA4World(oldA4);
  110. }
  111.